<form id="post-comment" class="robots-nocontent" method="post" action="<%== @form_action %>">

  <% if @comment && @comment.valid? %>
    <fieldset>
      <%= Thoth::CommentController.render_view(:comment, :comment => @comment) %>
    </fieldset>
  <% end %>

  <fieldset>
    <legend>New comment</legend>

    <p>
      <label for="author">Name</label>
      <input type="text" name="author" id="author" maxlength="32"
          title="Enter your name" value="<%== @author %>" />
    </p>

    <% if @comment; @comment.errors.on_field(:author).each do |error| %>
      <div class="flash error"><%== error %></div>
    <% end; end %>

    <p>
      <label for="author_email">Email</label>
      <input type="text" name="author_email" id="author_email" maxlength="255"
          title="Enter your email address" value="<%== @author_email %>" />
      <span class="tip">required, won't be displayed (but may be used for Gravatar)</span>
    </p>

    <% if @comment; @comment.errors.on_field(:author_email).each do |error| %>
      <div class="flash error"><%== error %></div>
    <% end; end %>

    <p>
      <label for="author_url">Website</label>
      <input type="text" name="author_url" id="author_url" maxlength="255"
          title="Enter the URL of your website (optional)"
          value="<%== @author_url %>" />
      <span class="tip">optional</span>
    </p>

    <% if @comment; @comment.errors.on_field(:author_url).each do |error| %>
      <div class="flash error"><%== error %></div>
    <% end; end %>

    <p>
      <textarea name="body" rows="15" cols="60"><%== @comment && @comment.body ? @comment.body : '' %></textarea>
    </p>

    <% if @comment; @comment.errors.on_field(:body).each do |error| %>
      <div class="flash error"><%== error %></div>
    <% end; end %>

    <p class="noseeum">
      Don't type anything here unless you're an evil robot:<br />
      <input type="text" id="captcha" name="captcha" maxlength="50" />

      <br /><br />
      And especially don't type anything here:<br />
      <textarea name="comment" rows="6" cols="60"></textarea>
    </p>

    <% if @comment_error %>
      <div class="flash error"><%== @comment_error %></div>
    <% end %>

    <p>
      <input type="submit" name="action" value="Preview Comment" />
      <input type="submit" name="action" value="Post Comment" />
      <input type="hidden" name="post_id" value="<%== @post.id %>" />
      <input type="hidden" name="comment_id"
          value="<%== @comment && @comment.id ? @comment.id : '' %>" />
    </p>

    <p class="tip">
      Basic HTML (including links) is allowed, just don't try anything fishy.
      Your comment will be auto-formatted unless you use your own
      <code>&lt;p&gt;</code> tags for formatting. You're also welcome to use
      <a href="http://redcloth.org/textile" target="_blank">Textile</a>.
    </p>
  </fieldset>
</form>
